import { TreasuresCfgBase } from "./Sheets"
import { SheetManager } from "../../ccc3-framework-core/framework/modules/sheetManager";
export class TreasuresCfg extends TreasuresCfgBase {
  //id索引
  public static get(id: any) {
    if ((this as any)[id]) return (this as any)[id];
    return SheetManager.get("TreasuresCfg", id, TreasuresCfg);
  }
  public static getAll(): TreasuresCfg[] {
    return SheetManager.getAllSheets("TreasuresCfg", TreasuresCfg);
  }

  public static getTreasuresCfgByLevel(lv: number): TreasuresCfg {
    let all = this.getAll();
    let sortAll = all.sort((a, b) => {
      return b.ID - a.ID;
    });
    let findItem = sortAll.find(item => item.ID == lv);
    if (findItem) {
      return findItem;
    }
    else {
      if (lv == 0) {
        return sortAll[sortAll.length - 1];
      }
      return sortAll[0];
    }
  }
}